Imports System.IO

Namespace OpenArchive
	Namespace IO
		Public Class ArchiveBinaryWriter
			Inherits BinaryWriter
			Public Sub New(ByVal output As Global.System.IO.Stream)
				MyBase.New(output, New Global.System.Text.ASCIIEncoding)
			End Sub
			Public Sub New(ByVal output As Global.System.IO.Stream, ByVal encoding As Global.System.Text.Encoding)
				MyBase.New(output, encoding)
			End Sub
			''' <summary>
			''' Writes a character array to the current stream and advances the current position of the stream in accordance with the Encoding used and the specific characters being written to the stream.
			''' </summary>
			''' <param name="ch">A character array containing the data to write.</param>
			''' <remarks></remarks>
			<Obsolete("Use Write (ByVal value as String ", True)> _
   Public Overloads Sub Write(ByVal ch() As Char)
				If ch.Length = 0 Or ch Is Nothing Then
					Write(False)
				Else
					Write(True)
					MyBase.Write(ch)
				End If
			End Sub
			''' <summary>
			''' Writes a section of a character array to the current stream, and advances the current position of the stream in accordance with the Encoding used and perhaps the specific characters being written to the stream. 
			''' </summary>
			''' <param name="ch">A character array containing the data to write.</param>
			''' <param name="index">The starting point in buffer from which to begin writing.</param>
			''' <param name="count">The number of characters to write.</param>
			''' <remarks></remarks>
			<Obsolete("Use Write (ByVal value as String ", True)> _
   Public Overloads Sub Write(ByVal ch() As Char, ByVal index As Integer, ByVal count As Integer)
				If ch.Length = 0 Or ch Is Nothing Then
					Write(False)
				Else
					Write(True)
					MyBase.Write(ch, index, count)
				End If

			End Sub
			''' <summary>
			'''  Writes a byte array to the underlying stream.
			''' </summary>
			''' <param name="buffer">A byte array containing the data to write.</param>
			''' <remarks></remarks>
			Public Overloads Sub Write(ByVal buffer() As Byte)
				If buffer.Length = 0 Or buffer Is Nothing Then
					Write(False)
				Else
					Write(True)
					Write(buffer.LongLength)
					MyBase.Write(buffer)
				End If
			End Sub
			''' <summary>
			''' Writes a region of a byte array to the current stream.
			''' </summary>
			''' <param name="buffer">A byte array containing the data to write</param>
			''' <param name="index">The starting point in buffer at which to begin writing.</param>
			''' <param name="count">The number of bytes to write.</param>
			''' <remarks></remarks>
			Public Overloads Sub Write(ByVal buffer() As Byte, ByVal index As Integer, ByVal count As Integer)
				If buffer.Length = 0 Or buffer Is Nothing Then
					Write(False)
				Else
					Write(True)
					MyBase.Write(buffer, index, count)
				End If
			End Sub
			''' <summary>
			''' Writes a length-prefixed string to this stream in the current encoding of the BinaryWriter, and advances the current position of the stream in accordance with the encoding used and the specific characters being written to the stream.
			''' </summary>
			''' <param name="value">The value to write.</param>
			''' <remarks></remarks>
			Public Overloads Sub Write(ByVal value As String)
				If String.IsNullOrEmpty(value) Then
					Write(False)
				Else
					Write(True)
					MyBase.Write(value)
				End If
			End Sub
			'''
			''' <summary>
			''' 
			''' </summary>
			''' <param name="value">The version to write</param>
			''' <remarks></remarks>
			Public Overloads Sub Write(ByVal value As Version)
				If value Is Nothing Then
					Write(False)
				Else
                    Write(True)
                    Write(value.Major)
                    Write(value.Minor)
                    If value.Build = -1 Then
                        Write(CInt(0))
                    Else
                        Write(value.Build)
                    End If
                    If value.Revision = -1 Then
                        Write(CInt(0))
                    Else
                        Write(value.Revision)
                    End If
                End If
            End Sub
		End Class
	End Namespace
End Namespace

